package com.example.exceptionhandling.unit2;

class Demo
{
    int div() throws ArithmeticException,ArrayIndexOutOfBoundsException
    {
        int []arr = new int [4];

        System.out.println(arr[4]);

        return 4 / 0;
    }
}


class ExceptionDemo
{
    public static void main(String[]args)
    {
        Demo d = new Demo();

        try
        {
            int x = d.div();

            System.out.println("x="+x);
        }
        catch (ArithmeticException e)
        {
            System.out.println(e.toString());
        }
        catch (ArrayIndexOutOfBoundsException e)
        {
            System.out.println(e.toString());
        }
        catch (Exception e)
        {
            System.out.println(e.toString());
        }



        System.out.println("Over");
    }

}